package com.copa.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author copa
 * @createDate 2021-01-09 14:45
 * @function 订单状态
 */

@Getter
@AllArgsConstructor
public enum OrderStatusConstant {
    /**
     * 订单状态：
     * 0未支付
     * 1已支付未发货
     * 2已发货
     * 3用户取消 （未支付）
     * 4店家取消（支付与未支付都一样）
     * 5已发货部分商品取消或退款
     * 6已退款
     */

    WAITPAY(0,"未支付"),
    PAY(1,"已支付未发货"),
    SHIPPED(2,"已发货"),
    USERCANCEL(3,"用户取消（未支付）"),
    STORECANCEL(4,"店家取消（支付与未支付都一样）"),
    PARTREFUND(5,"已发货但存在商品退款"),
    REFUND(6,"全商品退款");

    private Integer orderStatus;

    private String statusDesc;


    public static String getDescByValue(short value) {
        for (OrderStatusConstant enums : OrderStatusConstant.values()) {
            if (enums.getOrderStatus() == value) {
                return enums.getStatusDesc();
            }
        }
        return "";
    }

    public static OrderStatusConstant parse(short value){
        for (OrderStatusConstant enums : OrderStatusConstant.values()) {
            if (enums.getOrderStatus() == value) {
                return enums;
            }
        }
        throw new IllegalArgumentException("无法查找到该类型");
    }

}
